package com.aaa.book_mall.dao.impl;

import com.aaa.book_mall.dao.OutAuditDao;
import com.aaa.book_mall.entity.OutAudit;
import com.aaa.book_mall.util.JDBCUtil;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Description: t_outaudit表的实现类
 * @ClassName: OutAuditDaoImpl
 * @Author: fengyun
 * @Date: 2021/1/20 22:17
 * @Version: 1.0
 */
@Repository
public class OutAuditDaoImpl implements OutAuditDao {
    @Override
    public int insertInfo(OutAudit outAudit) {
        String sql="insert into t_outaudit values(null,?,?,?,?,?,?,?)";
        int i = JDBCUtil.update(sql, outAudit.getOutauditnumber(), outAudit.getAudit_staffid(), outAudit.getAudit_staffname(),
                outAudit.getOut_outnumber(), outAudit.getAudit_result(), outAudit.getAudit_info(), outAudit.getAudit_date()
        );
        return i;
    }

    @Override
    public List<Map<String, Object>> selectAllAudit(OutAudit outAudit) {
        String sql="select * from t_outaudit limit ?,?";
        List<Map<String, Object>> maps = JDBCUtil.queryListMap(sql,(outAudit.getPage()-1)*outAudit.getLimit(),outAudit.getLimit());
        return maps;
    }

    @Override
    public int countAudit() {
        String sql="select count(*) from t_outaudit";
        List<List> lists = JDBCUtil.queryList(sql);
        int count=0;
        if(lists.size()>0){
            count=Integer.parseInt(lists.get(0).get(0).toString());
        }
        return count;
    }
}
